{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys \n",
    "sys.path.append(r\"C:\\Users\\user\\OneDrive\\myGit\\mod\\lib\")\n",
    "from req.faceServerAPI import qdfaceServerAPI\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "import json ,pickle,doctest\n",
    "class Test_qdfaceAPI:\n",
    "    def __init__(self):\n",
    "        self.req = qdfaceServerAPI('http://localhost:9001')\n",
    "        self.imagesPathList = [r\"X:\\share\\image\\mydataset\\test_img\\amellanby\\amellanby1.jpg\",\n",
    "                      r\"X:\\share\\image\\mydataset\\test_img\\amellanby\\amellanby2.jpg\",\n",
    "                      r\"C:\\Users\\user\\Pictures\\2002\\07\\19\\big\\foo\\img_18.jpg\"]\n",
    "\n",
    "    def test_get_image_feature(self):\n",
    "        \"\"\"\n",
    "        \"\"\"\n",
    "        r=self.req.get_image_feature(self.imagesPathList[0])\n",
    "        #print(r[:100])\n",
    "        d=json.loads(r)\n",
    "        \n",
    "        o=d[\"feature\"].encode(\"cp437\")\n",
    "        o=pickle.loads(o)\n",
    "        o=pickle.loads(o)\n",
    "        print(type(o))\n",
    "        print(type(d))\n",
    "        return d\n",
    "    \n",
    "    def test_feature2feature(self):\n",
    "        f1=self.req.get_image_feature(self.imagesPathList[0])\n",
    "        f2=self.req.get_image_feature(self.imagesPathList[1])\n",
    "        f1=json.loads(f1);f2=json.loads(f2)\n",
    "        r=self.req.feature2feature(f1[\"feature\"],f2[\"feature\"])\n",
    "        print(r)\n",
    "        return r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'numpy.ndarray'>\n",
      "<class 'dict'>\n",
      "<html><title>400: Bad Request</title><body>400: Bad Request</body></html>\n"
     ]
    }
   ],
   "source": [
    "req=Test_qdfaceAPI()\n",
    "r=req.test_get_image_feature()\n",
    "r2=req.test_feature2feature()\n",
    "\n",
    "# import doctest\n",
    "# doctest.testmod()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "def factorial(n):\n",
    "      pass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "'Test_qdfaceAPI' object has no attribute 'faceServerAPI'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-9-12a954fea7c3>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mimportlib\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mimportlib\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreload\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mreq\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfaceServerAPI\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mqdfaceServerAPI\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m: 'Test_qdfaceAPI' object has no attribute 'faceServerAPI'"
     ]
    }
   ],
   "source": [
    "import importlib\n",
    "importlib.reload(req.faceServerAPI.qdfaceServerAPI)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
